package com.dykj.fireFighting.server.elasticsearch.device.service.impl;

import com.dykj.fireFighting.api.elasticsearch.device.entity.EsDevice;
import com.dykj.fireFighting.api.elasticsearch.device.service.EsDeviceService;
import com.dykj.fireFighting.server.elasticsearch.device.repository.EsDeviceRepository;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;


/**
 * Service实现类
 * Created by macro on 2018/6/19.
 */
@Slf4j
@DubboService
public class EsDeviceServiceImpl implements EsDeviceService {


    @Autowired
    private EsDeviceRepository esDeviceRepository;

    @Override
    public Page<EsDevice> search(String keyword, Integer pageNum, Integer pageSize) {
        Pageable pageable = PageRequest.of(pageNum, pageSize);
        return esDeviceRepository.findByNameOrRelationId(keyword, keyword, pageable);
    }
}
